package com.topwalk.step01;

import lombok.extern.slf4j.Slf4j;

import java.io.IOException;
import java.io.PipedReader;
import java.io.PipedWriter;
import java.sql.SQLOutput;

/**
 * Join方法示例
 *
 * @author tang
 * @since 2023/10/13
 */
@Slf4j
public class Demo5_6Join {
    
    static class ThreadA implements Runnable {

        @Override
        public void run() {
            try {
                log.debug("我是子线程，我先睡一秒！");
                Thread.sleep(1000);
                log.debug("我是子线程，我睡完了一秒");
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }

    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(new ThreadA());
        thread.start();
        thread.join();
        log.debug("如果不加Join方法，我会被先打印出来，加了就在子线程执行完成后");
    }
    
    
}
